package com.yesep.learn.netty.tcp.protocol.common;

/**
 * @Description: 请求命令方向
 */
public enum CN_TARGET {

	DOWN(1, "上位机向现场端"), UP(2, "现场端向上位机"), BOTH(3, "双向");

	private Integer code;//编号
	private String message;//描述

	private CN_TARGET(Integer code, String message) {
		this.code = code;
		this.message = message;
	}

	public Integer getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

	@Override
	public String toString() {
		return this.name() + "(" + this.code + " | " + this.message + ")";
	}

	public static CN_TARGET get(int code) {
		for (CN_TARGET e : CN_TARGET.values()) {
			if (e.getCode() == code) {
				return e;
			}
		}
		return null;
	}
}
